package 反射.T5;

import java.lang.reflect.Field;

public class T5 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException {

        Class<?> aClass = Class.forName("反射.T5.Cat");
        Object obj = aClass.newInstance();
        Field fName = aClass.getDeclaredField("name");
        fName.setAccessible(true);
        fName.set(obj,"大黄");
        System.out.println(((Cat)obj).getName());


    }
}
